package com.project.psc.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.psc.bean.InviteBean;
import com.project.psc.bean.InviteSupplierBean;
import com.project.psc.dto.SupplierDto;
import com.project.psc.service.IInviteService;
import com.project.psc.util.SupplierThreadLocal;
import com.project.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;

@RestController
@RequestMapping("invite")
public class InviteController {
    @Autowired
    private IInviteService inviteService;

    @GetMapping("cutByItem")
    public ResultVo cutByItem(Integer pageNO, Integer status, String title,
                              LocalDate startDate, LocalDate endDate) {
        SupplierDto loginUser = SupplierThreadLocal.getSupplier();

        IPage<InviteSupplierBean> inviteSupplierBeanIPage = inviteService.cutByItem(pageNO, status, title, startDate, endDate, loginUser.getId());


        return ResultVo.ok(inviteSupplierBeanIPage);
    }

    @GetMapping("findById")
    public ResultVo findById(Long id) {
        InviteBean byId = inviteService.findById(id);
        return ResultVo.ok(byId);
    }


}
